package cz.cvut.manatee.processManager;

public abstract class ContainsCQLQuery extends ContainsCorpusQuery {
	
	/*
	 * CQL dotaz se kterym bude dotaz pracovat
	 */
	protected final String CQL;

	/*
	 * pripocteni score pri shode s CQL
	 */
	protected static int compareEqualCQL = 50; 
	
	public ContainsCQLQuery(String corpusName, String CQL){
		super(corpusName);
		this.CQL = CQL;
	}
	
	
	public String getCQL() {
		return this.CQL;
	}
	
	@Override
	public int compare(Query dotaz) {
		if (dotaz != null) {
			int predek = super.compare(dotaz);
			
			if (predek > 0) {
				if(dotaz instanceof ContainsCQLQuery) {
					ContainsCQLQuery novy_dotaz = (ContainsCQLQuery)dotaz;
					if (novy_dotaz.getCQL().equalsIgnoreCase( this.getCQL() )) {
						return predek+ContainsCQLQuery.compareEqualCQL;
					}
				}
				return predek;
			}
		}
		return 0;
	}
	
	/*
	 * Vypisuje svuj obsah
	 */
	public String toString() {
		return super.toString()+", \""+this.CQL+"\"";
	}
}
